/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package bpmn.impl;

import bpmn.Artifact;
import bpmn.ArtifactOutput;
import bpmn.BpmnPackage;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Artifact Output</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link bpmn.impl.ArtifactOutputImpl#getArtifactRef <em>Artifact Ref</em>}</li>
 *   <li>{@link bpmn.impl.ArtifactOutputImpl#getProduceAtCompletion <em>Produce At Completion</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ArtifactOutputImpl extends BPMNElementImpl implements ArtifactOutput {
	/**
	 * The cached value of the '{@link #getArtifactRef() <em>Artifact Ref</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getArtifactRef()
	 * @generated
	 * @ordered
	 */
	protected Artifact artifactRef;

	/**
	 * The default value of the '{@link #getProduceAtCompletion() <em>Produce At Completion</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getProduceAtCompletion()
	 * @generated
	 * @ordered
	 */
	protected static final Boolean PRODUCE_AT_COMPLETION_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getProduceAtCompletion() <em>Produce At Completion</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getProduceAtCompletion()
	 * @generated
	 * @ordered
	 */
	protected Boolean produceAtCompletion = PRODUCE_AT_COMPLETION_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ArtifactOutputImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return BpmnPackage.Literals.ARTIFACT_OUTPUT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Artifact getArtifactRef() {
		if (artifactRef != null && artifactRef.eIsProxy()) {
			InternalEObject oldArtifactRef = (InternalEObject)artifactRef;
			artifactRef = (Artifact)eResolveProxy(oldArtifactRef);
			if (artifactRef != oldArtifactRef) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, BpmnPackage.ARTIFACT_OUTPUT__ARTIFACT_REF, oldArtifactRef, artifactRef));
			}
		}
		return artifactRef;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Artifact basicGetArtifactRef() {
		return artifactRef;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setArtifactRef(Artifact newArtifactRef) {
		Artifact oldArtifactRef = artifactRef;
		artifactRef = newArtifactRef;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BpmnPackage.ARTIFACT_OUTPUT__ARTIFACT_REF, oldArtifactRef, artifactRef));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Boolean getProduceAtCompletion() {
		return produceAtCompletion;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setProduceAtCompletion(Boolean newProduceAtCompletion) {
		Boolean oldProduceAtCompletion = produceAtCompletion;
		produceAtCompletion = newProduceAtCompletion;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BpmnPackage.ARTIFACT_OUTPUT__PRODUCE_AT_COMPLETION, oldProduceAtCompletion, produceAtCompletion));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case BpmnPackage.ARTIFACT_OUTPUT__ARTIFACT_REF:
				if (resolve) return getArtifactRef();
				return basicGetArtifactRef();
			case BpmnPackage.ARTIFACT_OUTPUT__PRODUCE_AT_COMPLETION:
				return getProduceAtCompletion();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case BpmnPackage.ARTIFACT_OUTPUT__ARTIFACT_REF:
				setArtifactRef((Artifact)newValue);
				return;
			case BpmnPackage.ARTIFACT_OUTPUT__PRODUCE_AT_COMPLETION:
				setProduceAtCompletion((Boolean)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case BpmnPackage.ARTIFACT_OUTPUT__ARTIFACT_REF:
				setArtifactRef((Artifact)null);
				return;
			case BpmnPackage.ARTIFACT_OUTPUT__PRODUCE_AT_COMPLETION:
				setProduceAtCompletion(PRODUCE_AT_COMPLETION_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case BpmnPackage.ARTIFACT_OUTPUT__ARTIFACT_REF:
				return artifactRef != null;
			case BpmnPackage.ARTIFACT_OUTPUT__PRODUCE_AT_COMPLETION:
				return PRODUCE_AT_COMPLETION_EDEFAULT == null ? produceAtCompletion != null : !PRODUCE_AT_COMPLETION_EDEFAULT.equals(produceAtCompletion);
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (ProduceAtCompletion: ");
		result.append(produceAtCompletion);
		result.append(')');
		return result.toString();
	}

} //ArtifactOutputImpl
